package com.suarte.core;

import org.appfuse.model.BaseObject;

import javax.persistence.*;

/**
 * Created by IntelliJ IDEA.
 * User: gcastillo
 * Date: Feb 4, 2011
 * Time: 11:14:01 PM
 * To change this template use File | Settings | File Templates.
 */

@Entity
@Table(name = "sa_invoice_payments")
public class InvoicePayment extends BaseObject {
    private Long id;
    private Invoice invoice;
    private Payment payment;
    private Float amount;
    private Float localAmount;
    private Float foreignAmount;

    public InvoicePayment(){
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "INVOICE_PAYMENT_SEQ")
    @SequenceGenerator(name = "INVOICE_PAYMENT_SEQ", sequenceName = "INVOICE_PAYMENT_SEQ", allocationSize = 1)
    public Long getId() {
        return id;
    }

    @ManyToOne
    @JoinColumn(name="invoice_id")
    public Invoice getInvoice() {
        return invoice;
    }

    @ManyToOne
    @JoinColumn(name="payment_id")
    public Payment getPayment() {
        return payment;
    }

    public Float getAmount() {
        return amount;
    }

    public Float getLocalAmount() {
        return localAmount;
    }

    public Float getForeignAmount() {
        return foreignAmount;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    public void setLocalAmount(Float localAmount) {
        this.localAmount = localAmount;
    }

    public void setForeignAmount(Float foreignAmount) {
        this.foreignAmount = foreignAmount;
    }

    @Override
    public String toString() {
        return payment.toString();
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (!(other instanceof InvoicePayment)) {
            return false;
        }
        InvoicePayment _i = (InvoicePayment) other;
        return id.equals(_i.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
